/*
 * @Author: szx
 * @Date: 2022-03-26 14:40:33
 * @LastEditTime: 2022-03-26 14:44:48
 * @Description:
 * @FilePath: \leetcode\300-399\377\377_2.js
 */
/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */
var combinationSum4 = function (nums, target) {
    const dp = new (target + 1).fill(0);
    dp[0] = 1;
    for (let i = 1; i <= target; i++) {
        for (let j = 0; j < nums.length; j++) {
            if (i - nums[j] < 0) continue;
            dp[i] += dp[i - nums[j]];
        }
    }
    return dp[target];
};
